package Listener;

import javax.servlet.http.*;

public class SessionListenerTest implements HttpSessionListener, HttpSessionAttributeListener {
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("Session已经建立");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("Session已经销毁");
    }

    @Override
    public void attributeAdded(HttpSessionBindingEvent se) {
        System.out.println("Session已经添加");
        System.out.println(se.getSession()+"---"+se.getName()+"----"
        +se.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent se) {
        System.out.println("Session已经失效");
        HttpSession session = se.getSession();
        session.setAttribute("","");
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent se) {
        System.out.println("Session已经被覆盖或修改");
    }
}
